<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    #box{
        width: 200px;
        height: 200px;
        background-color: skyblue;
    }
</style>
<body>
    <button id="open">打开</button><button id="close">关闭</button>
    <script>
        class Model{
            static getDiv(){//静态方法
                if(!Model.div){
                    Model.div = document.createElement("div")
                    Model.div.innerHTML = "打开了弹框"
                    Model.div.style.display = "none" 
                    Model.div.id = "box"
                document.body.appendChild(Model.div)
                }
                return Model.div
            }
        }
        document.getElementById("open").addEventListener("click",()=>{
            // console.log(000);
            let aa = Model.getDiv()
            aa.style.display = "block"
        })
        document.getElementById("close").addEventListener("click",()=>{
            // console.log(000);
            let aa = Model.getDiv()
            aa.style.display = "none"
        })






    </script>
</body>
</html>